
traveler_ids = [('USA', '31195855'), ('BRA', 'CER3022'), ('ESP', 'PSD2324')]

for passport in traveler_ids:
    print('%s/%s' % passport)

for country, _ in traveler_ids:
    print(country)

my_list = [['abc']]
print(my_list)

list1 = my_list * 3

print(list1)

list1[0][0] = 'xyz'
print(list1)
print(my_list)

#元组拆包
favorit_pert = ('cat', 'dog')
kind1, kind2 = favorit_pert
print(kind1, kind2)

a, b, *rest = range(5)
print(a, b, rest)

#使用嵌套元组获取成绩
students = [
    ('小明', '21', '计算机科学技术', (80, 78, 90)),
    ('小红', '21', '计算机科学技术', (80, 78, 90)),
    ('小军', '21', '计算机科学技术', (80, 78, 90)),
]
for name, age, object_, (chinese, math, english) in students:
    print(name, age, object_, chinese, math, english)
    print('\n')

#定义和使用具名元组
from collections import namedtuple
Student = namedtuple('Student', 'name age object_ score')
student = Student('小明', '21', '计算机科学技术', (80, 78, 90))
print(student)
print(student.name)
print(student.score)

#具名元组的属性和方法
print(Student._fields)

student2_data =  ('小军', '21', '计算机科学技术', (80, 78, 90))
student2 = Student._make(student2_data)
print(student2.name)
print(student2._asdict)